package com.leaves.leetcode.array.t1534_CountGoodTriplets;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.leaves.leetcode.UnitTesting;

import java.util.List;

public class T1534Main extends UnitTesting<Object[], Integer> {

    Solution solution = new Solution();

    @Override
    protected void generateTestData() {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            testDataList.add(createTestData(
                    objectMapper.readValue("[[3,0,1,1,9,7], 7, 2, 3]", new TypeReference<Object[]>() {}),
                    4
            ));
            testDataList.add(createTestData(
                    objectMapper.readValue("[[1,1,2,2,3], 0, 0, 1]", new TypeReference<Object[]>() {}),
                    0
            ));

        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public Integer run(Object[] inputData) {
        int[] arr;
        List<Integer> list = (List<Integer>) inputData[0];
        arr = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            arr[i] = list.get(i);
        }
        int a = (int) inputData[1];
        int b = (int) inputData[2];
        int c = (int) inputData[3];

        return solution.countGoodTriplets(arr, a, b, c);
    }
}
